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

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

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

c = A("c")
i = B("i")
j = C("j")
h = A("h")
k = C("k")
n = B("n")
l = A("l")
f = A("f")
d = A("d")
a = A("a")

c.t = n
i.y = n
i.p = k
j.u = n
j.v = l
h.t = n
k.u = i
k.v = a
n.y = i
n.p = j
l.t = n
f.t = n
d.t = i
a.t = n
assert h.t.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

c = A("c")
i = B("i")
j = C("j")
h = A("h")
k = C("k")
n = B("n")
l = A("l")
f = A("f")
d = A("d")
a = A("a")

c.t = n
i.y = n
i.p = k
j.u = n
j.v = l
h.t = n
k.u = i
k.v = a
n.y = i
n.p = j
l.t = n
f.t = n
d.t = i
a.t = n
assert h.t.p.v.txt == "l"