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

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

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

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

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

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

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