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

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

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

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

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

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

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