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

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

k = A("k")
j = B("j")
g = B("g")
c = A("c")
f = B("f")
a = B("a")
i = B("i")

k.p = c
j.t = k
j.y = f
g.t = c
g.y = j
c.p = k
f.t = c
f.y = i
a.t = c
a.y = j
i.t = c
i.y = f
assert i.t.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

k = A("k")
j = B("j")
g = B("g")
c = A("c")
f = B("f")
a = B("a")
i = B("i")

k.p = c
j.t = k
j.y = f
g.t = c
g.y = j
c.p = k
f.t = c
f.y = i
a.t = c
a.y = j
i.t = c
i.y = f
assert i.t.p.p.txt == "c"