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

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

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

l = A("l")
n = B("n")
c = C("c")
j = B("j")
i = C("i")
m = A("m")

l.q = c
l.p = i
n.u = i
n.x = c
c.o = i
j.u = c
j.x = i
i.o = c
m.q = c
m.p = i
assert m.q.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: C = None
        self.txt = txt

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

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

l = A("l")
n = B("n")
c = C("c")
j = B("j")
i = C("i")
m = A("m")

l.q = c
l.p = i
n.u = i
n.x = c
c.o = i
j.u = c
j.x = i
i.o = c
m.q = c
m.p = i
assert m.q.o.o.o.o.o.txt == "i"