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

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

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

g = A("g")
d = B("d")
c = C("c")
l = B("l")
m = A("m")
h = B("h")
n = C("n")
j = B("j")
f = C("f")

g.u = f
d.r = h
d.z = f
c.x = l
c.p = d
l.r = h
l.z = f
m.u = c
h.r = d
h.z = n
n.x = d
n.p = h
j.r = d
j.z = c
f.x = d
f.p = d
assert d.r.z.p.z.x.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

g = A("g")
d = B("d")
c = C("c")
l = B("l")
m = A("m")
h = B("h")
n = C("n")
j = B("j")
f = C("f")

g.u = f
d.r = h
d.z = f
c.x = l
c.p = d
l.r = h
l.z = f
m.u = c
h.r = d
h.z = n
n.x = d
n.p = h
j.r = d
j.z = c
f.x = d
f.p = d
assert d.r.z.p.z.x.z.x.txt == "d"