
191 N.W.2d 573 (1971)
LEO LUMBER COMPANY, a corporation, Plaintiff and Appellant,
v.
Jack WILLIAMS and First Federal Savings and Loan Association of Fargo, a corporation, Defendants, and
First Federal Savings and Loan Association of Fargo, a corporation, Defendant and Respondent.
Civ. No. 8745.
Supreme Court of North Dakota.
November 12, 1971.
*574 Wattam, Vogel, Vogel & Peterson, Fargo, for plaintiff and appellant.
*575 Tenneson, Serkland, Lundberg & Erickson, Fargo, for defendant and respondent.
KNUDSON, Judge.
This is an appeal from a judgment in favor of the First Federal Savings and Loan Association of Fargo dismissing the complaint of Leo Lumber Company. The complaint had been dismissed as to the defendant Jack Williams earlier in the proceedings. No appeal was taken from the judgment dismissing the complaint as to the defendant Jack Williams.
The complaint of Leo Lumber in this action alleges a contract between First Federal and Leo Lumber to furnish building materials for the construction of a dwelling by Jackson Company; that First Federal held a mortgage on said premises, executed to provide funds to finance the construction of the dwelling; that First Federal would make sure and see to it that Leo Lumber was paid in full for all building materials out of the mortgage loan funds which First Federal was providing and administering; and that Leo Lumber provided building materials for the construction of said dwelling.
Leo Lumber asserts that its claim in the present action is grounded on the promise of First Federal to pay out of the loan funds to Jackson Company the cost of the building materials furnished by Leo Lumber to Jackson Company; that, therefore, the claim of Leo Lumber against First Federal is wholly separate and distinct from the mortgage foreclosure action brought by First Federal against the Jackson Company.
First Federal asserts that there was but one transaction and occurrence arising out of the subject matter wherein Leo Lumber sold to Jackson Company building materials, payment for which was to be made from the proceeds of a loan by First Federal to Jackson Company.
The present action of Leo Lumber against First Federal was for the balance owing on the cost of the materials furnished by Leo Lumber to the Jackson Company for the construction of the dwelling house on the mortgaged premises.
The claim of Leo Lumber in the present action is based upon the alleged promise by First Federal to pay Leo Lumber out of the loan proceeds for the materials furnished by Leo Lumber to the Jackson Company.
First Federal made a motion for summary judgment to dismiss the complaint of Leo Lumber upon the grounds that it had failed to plead as a compulsory counterclaim in a foreclosure action brought by First Federal against the Jackson Company and others, including Leo Lumber, its, Leo Lumber's, claim based on its agreement with First Federal.
First Federal contends that the claim in the present action by Leo Lumber against First Federal for the balance owing on the cost of the building materials furnished by Leo Lumber to the Jackson Company arose out of the same transaction or occurrence that was the subject of the mortgage foreclosure action brought by First Federal against the Jackson Company and others, including Leo Lumber, and that, therefore, the claim of Leo Lumber should have been pleaded as a compulsory counterclaim in the foreclosure action, and by the failure to so plead it is barred in the present action by Rule 13(a), North Dakota Rules of Civil Procedure.
The complaint by First Federal in the mortgage foreclosure action named the Jackson Company and Leo Lumber with others, as defendants and alleged the making of a real estate mortgage by the Jackson Company to First Federal upon Lot 4, Block 2, Country Club Acres Addition to the City of Fargo; that the mortgage is in default; that the defendants (including Leo Lumber) have, or claim to have, some estates or interests in, or liens or encumbrances upon said mortgaged premises. Leo Lumber had filed in the office of the register of deeds a mechanic's lien for the *576 balance owing by the Jackson Company to Leo Lumber for building materials furnished by Leo Lumber to the Jackson Company.
In that foreclosure action Leo Lumber interposed an answer asserting the priority of its mechanic's lien to the mortgage of First Federal, but did not counterclaim against First Federal its claim based upon its agreement with First Federal, which is now the subject of the present action. The trial court in the present action held that the claim of Leo Lumber against First Federal arose out of the same transaction or occurrence that was the subject matter of the claim of First Federal in the foreclosure action, and the failure to assert that claim by way of counterclaim in the previous foreclosure action barred Leo Lumber from asserting its claim against First Federal in the present action, as a compulsory counterclaim under Rule 13(a), N.D.R.Civ.P., which provides as follows:
(a) Compulsory counterclaims. A pleading shall state as a counterclaim any claim which at the time of serving the pleading the pleader has against any opposing party, if it arises out of the transaction or occurrence that is the subject matter of the opposing party's claim * * *. [Emphasis added.]
Rule 13(b), N.D.R.Civ.P., relating to permissive counterclaim, provides as follows:
(b) Permissive counterclaims. A pleading may state as a counterclaim any claim against an opposing party not arising out of the transaction or occurrence that is the subject matter of the opposing party's claim.
In order to decide the issue whether or not the prior action bars the present action, this court must first resolve the question whether the claim of Leo Lumber must be pleaded in the prior foreclosure action as a compulsory counterclaim or whether it is a permissive counterclaim under Rule 13(b), N.D.R.Civ.P., and need not be pleaded as a compulsory counterclaim in the prior foreclosure action.
Our Rule 13(a) and 13(b) are word for word the same as Rule 13(a) and 13(b) of the Federal Rules of Civil Procedure, and we may look to interpretation of that Rule as made by and decided by the Federal courts and discussed by text writers, as this court has not passed on the interpretation of Rule 13(a) of the North Dakota Rules of Civil Procedure.
On the question of whether the claim must be pleaded as a compulsory counterclaim in the prior action, the interpretation of the clause "transaction or occurrence that is the subject matter," should be made with a liberal, broad, realistic interpretation in the interest of avoiding a multiplicity of suits, as suggested by Professor Moore in 3 Moore's Federal Practice (2d ed.) in ¶ 13.13:
An all-embracing definition [of Rule 13(a)] cannot be given, nor is one desirable. The same flexibility and same empirical treatment is necessary in connection with "transaction or occurrence" that has been advocated and discussed in connection with "cause of action." [2 Moore's Federal Practice (2d ed.) ¶ 2.06] * * * [C]ourts should give the phrase "transaction or occurrence that is the subject matter" of the suit a broad realistic interpretation in the interest of avoiding a multiplicity of suits. Subject to the exceptions, any claim that is logically related to another claim that is being sued on is properly the basis for a compulsory counterclaim; only claims that are unrelated or are related, but within the exceptions, need not be pleaded.
And in 1A Barron and Holtzoff, Federal Practice and Procedure, § 394, page 573, the author states what has been correctly called "the one compelling test of compulsoriness,"

*577 Any claim which a party has against an opposing party which is logically related to the claim the opposing party is suing on and which is not within the exceptions listed in the rule is a compulsory counterclaim.
and is known as the logical relation test.
"If there be one compelling test of compulsoriness, it seems clearly to be that of the logical relationship of all claims in any given litigation." Rosenthal v. Fowler, D.C.N.Y.1952, 12 F.R.D. 388, 391.
Since a claim which arises out of the transaction or occurrence that is the subject matter of the opposing party's claim must be pleaded as a counterclaim or it is barred in a subsequent action, it becomes important to understand what is meant by that phrase. Having in mind what the authorities have said as to the definition and understanding of that phrase, we will discuss whether or not the claim of Leo Lumber is that kind of a claim which "arises out of the transaction or occurrence that is the subject matter" of the claim of First Federal against Jackson Company in the foreclosure action.
"Transaction" is a word of flexible meaning. It may comprehend a series of many occurrences, depending not so much upon the immediateness of their connections as upon their logical relationship. First Federal made a construction loan secured by a real estate mortgage to Jackson Company for the construction of a dwelling on the mortgaged premises; Leo Lumber furnished building materials to the Jackson Company to be used in the construction of that dwelling; Leo Lumber was to be paid by First Federal out of the loan proceeds for the cost of those materials. In this triangular affair First Federal was to furnish the money for the building of the dwelling, Jackson Company was to construct the dwelling, Leo Lumber was to furnish the building materials for the construction of the dwelling. First Federal was to pay Leo Lumber for the cost of the materials out of the proceeds of the loan. Leo Lumber asserts that there was a definite promise by First Federal to pay the cost of the materials out of the proceeds of the loan. First Federal disputes that there was a definite promise on its part to pay Leo Lumber for the cost of the materials, but First Federal, in this action, asserts that it is immaterial whether or not there was a definite promise because in the present action the claim of Leo Lumber arose out of the transaction or occurrence that was the subject matter of the claim of First Federal in the mortgage foreclosure action and, therefore, under Rule 13(a), N.D.R.Civ.P., must be pleaded as a compulsory counterclaim, and by the failure of Leo Lumber to counterclaim in the foreclosure action that claim of Leo Lumber is barred in the present action. In any event, it appears from the record that Leo Lumber was paid by First Federal from the loan proceeds upon the presentation by Jackson Company of statements of materials furnished by Leo Lumber and the cost thereof from time to time, and that upon the exhaustion of the mortgage loan proceeds First Federal made no further payments to Leo Lumber, leaving a balance due to Leo Lumber of $2,000.00. The payment by First Federal for the cost of the materials furnished by Leo Lumber to Jackson Company during the course of construction of the dwelling is one of the links in the chain in the transaction of the construction of the dwelling and the making of the loan upon which First Federal based its foreclosure action. This is an important part of the transaction constituting the subject matter of the loan by First Federal to Jackson Company. Essential facts alleged by Leo Lumber enter into and constitute a part of the claim set forth in the foreclosure action. The furnishing of the building materials by Leo Lumber is an occurrence within the transaction to build a dwelling. The making of the loan is an occurrence within the transaction to build a dwelling. The word "transaction" is broader in scope than the word "occurrence." The term "transaction" is broad enough to include an "occurrence." Since *578 the claim of Leo Lumber arose out of the transaction that is the subject matter of the foreclosure of mortgage action it should have been pleaded as a counterclaim in the foreclosure action, and is consequently barred in this action.
The judgment of the trial court dismissing the complaint of the plaintiff is affirmed.
STRUTZ, C. J., and PAULSON, ERICKSTAD and TEIGEN, JJ., concur.
