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

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

c = A("c")
j = B("j")
d = B("d")
n = A("n")
i = A("i")
e = A("e")
f = A("f")

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

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

c = A("c")
j = B("j")
d = B("d")
n = A("n")
i = A("i")
e = A("e")
f = A("f")

c.t = j
j.q = f
d.q = f
n.t = j
i.t = j
e.t = j
f.t = j
assert n.t.q.t.q.txt == "f"