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

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

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

d = A("d")
n = B("n")
h = C("h")
b = B("b")
m = A("m")
e = A("e")
f = B("f")
c = C("c")
a = C("a")

d.x = b
d.z = a
n.t = f
n.z = f
h.z = b
h.p = n
h.u = e
b.t = n
b.z = f
m.x = n
m.z = a
e.x = b
e.z = h
f.t = b
f.z = b
c.z = n
c.p = b
c.u = e
a.z = n
a.p = f
a.u = m
assert e.x.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.z: C = None
        self.txt = txt

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

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

d = A("d")
n = B("n")
h = C("h")
b = B("b")
m = A("m")
e = A("e")
f = B("f")
c = C("c")
a = C("a")

d.x = b
d.z = a
n.t = f
n.z = f
h.z = b
h.p = n
h.u = e
b.t = n
b.z = f
m.x = n
m.z = a
e.x = b
e.z = h
f.t = b
f.z = b
c.z = n
c.p = b
c.u = e
a.z = n
a.p = f
a.u = m
assert e.x.t.t.t.txt == "b"