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

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

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

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

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

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

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

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

b.z = e
b.p = d
e.w = c
e.z = a
e.x = n
f.u = a
f.q = n
f.y = c
h.z = n
h.p = d
n.w = h
n.z = d
n.x = e
d.u = f
d.q = n
d.y = b
a.u = f
a.q = e
a.y = b
c.z = e
c.p = d
assert h.p.y.z.w.p.u.txt == "f"