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

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

b = A("b")
d = B("d")
l = A("l")
k = A("k")
n = B("n")
j = B("j")

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

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

b = A("b")
d = B("d")
l = A("l")
k = A("k")
n = B("n")
j = B("j")

b.t = l
b.p = j
d.p = k
l.t = b
l.p = n
k.t = l
k.p = d
n.p = k
j.p = l
assert l.p.p.t.txt == "l"