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

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

k = A("k")
h = B("h")
b = B("b")
f = A("f")
c = B("c")
i = A("i")
j = A("j")
e = B("e")

k.u = b
h.p = f
h.t = c
b.p = k
b.t = c
f.u = h
c.p = k
c.t = b
i.u = c
j.u = c
e.p = i
e.t = b
assert j.u.t.p.u.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

k = A("k")
h = B("h")
b = B("b")
f = A("f")
c = B("c")
i = A("i")
j = A("j")
e = B("e")

k.u = b
h.p = f
h.t = c
b.p = k
b.t = c
f.u = h
c.p = k
c.t = b
i.u = c
j.u = c
e.p = i
e.t = b
assert j.u.t.p.u.t.t.t.t.txt == "b"