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

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

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

g = A("g")
d = B("d")
k = C("k")
e = A("e")
h = B("h")
f = C("f")
i = A("i")
c = A("c")
l = C("l")
b = C("b")

g.r = b
g.u = e
d.z = b
k.p = l
e.r = b
e.u = i
h.z = b
f.p = l
i.r = f
i.u = e
c.r = k
c.u = e
l.p = k
b.p = f
assert d.z.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.u: A = None
        self.txt = txt

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

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

g = A("g")
d = B("d")
k = C("k")
e = A("e")
h = B("h")
f = C("f")
i = A("i")
c = A("c")
l = C("l")
b = C("b")

g.r = b
g.u = e
d.z = b
k.p = l
e.r = b
e.u = i
h.z = b
f.p = l
i.r = f
i.u = e
c.r = k
c.u = e
l.p = k
b.p = f
assert d.z.p.p.txt == "l"