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

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

m = A("m")
c = B("c")
l = B("l")
g = B("g")
b = B("b")
j = B("j")
f = B("f")

m.t = j
c.w = m
c.t = m
l.w = m
l.t = m
g.w = m
g.t = m
b.w = m
b.t = m
j.w = m
j.t = m
f.w = m
f.t = m
assert j.t.t.t.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

m = A("m")
c = B("c")
l = B("l")
g = B("g")
b = B("b")
j = B("j")
f = B("f")

m.t = j
c.w = m
c.t = m
l.w = m
l.t = m
g.w = m
g.t = m
b.w = m
b.t = m
j.w = m
j.t = m
f.w = m
f.t = m
assert j.t.t.t.t.w.txt == "m"