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

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

f = A("f")
e = B("e")
b = B("b")
c = A("c")
j = A("j")

f.x = b
e.t = j
e.y = c
b.t = c
b.y = j
c.x = e
j.x = e
assert j.x.t.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

f = A("f")
e = B("e")
b = B("b")
c = A("c")
j = A("j")

f.x = b
e.t = j
e.y = c
b.t = c
b.y = j
c.x = e
j.x = e
assert j.x.t.x.y.txt == "c"