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

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

j = A("j")
g = B("g")
l = A("l")
f = B("f")

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

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

j = A("j")
g = B("g")
l = A("l")
f = B("f")

j.t = g
j.u = f
g.w = l
g.v = f
l.t = f
l.u = f
f.w = l
f.v = g
assert f.w.u.w.txt == "l"