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

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

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

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

d.z = h
c.v = h
c.x = d
c.z = l
g.t = l
l.z = h
n.t = l
h.z = l
assert c.x.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

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

d.z = h
c.v = h
c.x = d
c.z = l
g.t = l
l.z = h
n.t = l
h.z = l
assert c.x.z.z.z.z.z.txt == "h"