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

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

k = A("k")
d = B("d")
n = A("n")
g = B("g")
e = B("e")
b = A("b")
j = A("j")
c = A("c")
i = A("i")

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

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

k = A("k")
d = B("d")
n = A("n")
g = B("g")
e = B("e")
b = A("b")
j = A("j")
c = A("c")
i = A("i")

k.p = j
k.t = d
d.u = k
n.p = i
n.t = g
g.u = k
e.u = c
b.p = j
b.t = d
j.p = k
j.t = g
c.p = j
c.t = e
i.p = k
i.t = e
assert k.t.u.p.t.txt == "g"