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

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

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

b = A("b")
j = B("j")
e = C("e")
f = C("f")
k = B("k")
i = A("i")
c = A("c")
l = C("l")
a = C("a")

b.o = c
b.q = f
b.z = l
j.r = k
e.p = k
e.t = k
e.x = j
f.p = j
f.x = j
f.t = k
k.r = j
i.o = b
i.q = l
i.z = e
c.o = b
c.q = e
c.z = f
l.p = k
l.x = k
l.t = j
a.p = j
a.t = j
a.x = k
assert i.q.x.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.q: C = None
        self.z: C = None
        self.txt = txt

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

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

b = A("b")
j = B("j")
e = C("e")
f = C("f")
k = B("k")
i = A("i")
c = A("c")
l = C("l")
a = C("a")

b.o = c
b.q = f
b.z = l
j.r = k
e.p = k
e.t = k
e.x = j
f.p = j
f.x = j
f.t = k
k.r = j
i.o = b
i.q = l
i.z = e
c.o = b
c.q = e
c.z = f
l.p = k
l.x = k
l.t = j
a.p = j
a.t = j
a.x = k
assert i.q.x.r.r.r.r.txt == "k"