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

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

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

n = A("n")
l = B("l")
b = C("b")
j = B("j")
f = B("f")
d = B("d")
a = B("a")
m = B("m")
i = A("i")
h = B("h")

n.x = a
n.r = i
l.u = b
b.z = i
j.u = b
f.u = b
d.u = b
a.u = b
m.u = b
i.x = d
i.r = n
h.u = b
assert d.u.z.x.u.z.r.r.r.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: A = None
        self.txt = txt

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

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

n = A("n")
l = B("l")
b = C("b")
j = B("j")
f = B("f")
d = B("d")
a = B("a")
m = B("m")
i = A("i")
h = B("h")

n.x = a
n.r = i
l.u = b
b.z = i
j.u = b
f.u = b
d.u = b
a.u = b
m.u = b
i.x = d
i.r = n
h.u = b
assert d.u.z.x.u.z.r.r.r.r.x.txt == "d"