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

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

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

c = A("c")
b = B("b")
e = C("e")
n = A("n")
l = B("l")
d = A("d")

c.p = d
c.q = n
c.z = l
b.t = d
b.r = l
e.o = l
n.p = c
n.q = d
n.z = l
l.t = c
l.r = b
d.p = c
d.q = c
d.z = b
assert l.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: A = None
        self.z: B = None
        self.txt = txt

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

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

c = A("c")
b = B("b")
e = C("e")
n = A("n")
l = B("l")
d = A("d")

c.p = d
c.q = n
c.z = l
b.t = d
b.r = l
e.o = l
n.p = c
n.q = d
n.z = l
l.t = c
l.r = b
d.p = c
d.q = c
d.z = b
assert l.r.r.r.txt == "b"