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

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

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

l = A("l")
d = B("d")
n = C("n")
e = C("e")
k = B("k")
g = A("g")
j = B("j")
f = C("f")

l.p = e
l.o = d
d.z = l
d.p = l
d.x = g
n.q = f
e.q = f
k.z = l
k.x = g
k.p = g
g.p = e
g.o = d
j.z = l
j.p = l
j.x = g
f.q = n
assert d.x.o.x.p.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.o: B = None
        self.txt = txt

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

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

l = A("l")
d = B("d")
n = C("n")
e = C("e")
k = B("k")
g = A("g")
j = B("j")
f = C("f")

l.p = e
l.o = d
d.z = l
d.p = l
d.x = g
n.q = f
e.q = f
k.z = l
k.x = g
k.p = g
g.p = e
g.o = d
j.z = l
j.p = l
j.x = g
f.q = n
assert d.x.o.x.p.q.q.txt == "n"