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

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

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

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

n.y = d
b.y = d
b.u = m
h.t = n
h.y = m
h.v = d
d.y = n
m.y = n
m.u = b
a.t = n
a.v = n
a.y = b
assert a.t.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

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

n.y = d
b.y = d
b.u = m
h.t = n
h.y = m
h.v = d
d.y = n
m.y = n
m.u = b
a.t = n
a.v = n
a.y = b
assert a.t.y.y.y.y.txt == "n"