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

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

c = A("c")
b = B("b")
j = A("j")
l = A("l")

c.o = l
c.t = j
b.q = c
j.o = c
j.t = l
l.o = j
l.t = j
assert b.q.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.t: A = None
        self.txt = txt

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

c = A("c")
b = B("b")
j = A("j")
l = A("l")

c.o = l
c.t = j
b.q = c
j.o = c
j.t = l
l.o = j
l.t = j
assert b.q.t.t.t.txt == "j"