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

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

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

d = A("d")
b = B("b")
k = C("k")
i = C("i")
e = B("e")
c = B("c")
l = A("l")
m = A("m")

d.x = i
d.z = l
d.p = m
b.u = c
b.s = c
b.r = d
k.z = d
k.q = d
k.v = i
i.z = l
i.v = k
i.q = m
e.u = c
e.s = c
e.r = l
c.u = b
c.s = b
c.r = d
l.x = i
l.z = d
l.p = m
m.x = i
m.z = d
m.p = l
assert k.q.z.x.q.x.z.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.z: A = None
        self.p: A = None
        self.txt = txt

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

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

d = A("d")
b = B("b")
k = C("k")
i = C("i")
e = B("e")
c = B("c")
l = A("l")
m = A("m")

d.x = i
d.z = l
d.p = m
b.u = c
b.s = c
b.r = d
k.z = d
k.q = d
k.v = i
i.z = l
i.v = k
i.q = m
e.u = c
e.s = c
e.r = l
c.u = b
c.s = b
c.r = d
l.x = i
l.z = d
l.p = m
m.x = i
m.z = d
m.p = l
assert k.q.z.x.q.x.z.x.z.txt == "l"