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

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

k = A("k")
j = B("j")
b = B("b")
g = B("g")
a = B("a")
h = B("h")
e = A("e")
d = A("d")

k.u = d
j.t = k
j.v = k
b.t = k
b.v = e
g.t = e
g.v = e
a.t = d
a.v = k
h.t = k
h.v = d
e.u = k
d.u = k
assert h.t.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

k = A("k")
j = B("j")
b = B("b")
g = B("g")
a = B("a")
h = B("h")
e = A("e")
d = A("d")

k.u = d
j.t = k
j.v = k
b.t = k
b.v = e
g.t = e
g.v = e
a.t = d
a.v = k
h.t = k
h.v = d
e.u = k
d.u = k
assert h.t.u.u.u.u.txt == "k"