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

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

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

h = A("h")
c = B("c")
n = C("n")
g = A("g")
m = B("m")
j = A("j")
l = C("l")
i = C("i")

h.t = i
c.u = i
n.v = h
n.o = g
g.t = l
m.u = n
j.t = n
l.v = g
l.o = g
i.v = j
i.o = g
assert h.t.o.t.v.t.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

h = A("h")
c = B("c")
n = C("n")
g = A("g")
m = B("m")
j = A("j")
l = C("l")
i = C("i")

h.t = i
c.u = i
n.v = h
n.o = g
g.t = l
m.u = n
j.t = n
l.v = g
l.o = g
i.v = j
i.o = g
assert h.t.o.t.v.t.v.t.txt == "l"