class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: A = None
        self.txt = txt

g = A("g")
k = B("k")
b = B("b")
c = B("c")
j = B("j")

g.x = k
g.t = c
k.r = g
k.w = g
b.r = g
b.w = g
c.r = g
c.w = g
j.r = g
j.w = g
assert j.r.t.r.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: A = None
        self.txt = txt

g = A("g")
k = B("k")
b = B("b")
c = B("c")
j = B("j")

g.x = k
g.t = c
k.r = g
k.w = g
b.r = g
b.w = g
c.r = g
c.w = g
j.r = g
j.w = g
assert j.r.t.r.t.w.txt == "g"