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

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

c = A("c")
d = B("d")
h = A("h")
n = A("n")
l = B("l")

c.o = l
d.q = l
d.u = l
h.o = l
n.o = d
l.q = d
l.u = d
assert l.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

c = A("c")
d = B("d")
h = A("h")
n = A("n")
l = B("l")

c.o = l
d.q = l
d.u = l
h.o = l
n.o = d
l.q = d
l.u = d
assert l.q.q.q.q.q.txt == "d"