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

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

j = A("j")
b = B("b")
n = B("n")
e = B("e")
d = A("d")
g = A("g")
h = A("h")
c = A("c")
f = B("f")

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

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

j = A("j")
b = B("b")
n = B("n")
e = B("e")
d = A("d")
g = A("g")
h = A("h")
c = A("c")
f = B("f")

j.t = n
b.y = h
n.y = j
e.y = d
d.t = n
g.t = f
h.t = f
c.t = b
f.y = j
assert n.y.t.y.t.txt == "n"