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

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

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

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

h.u = i
h.v = i
h.p = d
n.t = a
n.r = d
b.w = d
b.x = i
b.u = a
i.u = h
i.v = h
i.p = d
a.t = n
a.r = d
d.w = b
d.x = i
d.u = n
assert i.v.p.u.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.v: A = None
        self.p: C = None
        self.txt = txt

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

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

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

h.u = i
h.v = i
h.p = d
n.t = a
n.r = d
b.w = d
b.x = i
b.u = a
i.u = h
i.v = h
i.p = d
a.t = n
a.r = d
d.w = b
d.x = i
d.u = n
assert i.v.p.u.t.t.t.txt == "a"