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.p: A = None
        self.txt = txt

b = A("b")
n = B("n")
c = B("c")
l = A("l")
m = B("m")
a = B("a")
f = B("f")
h = B("h")
d = A("d")
j = B("j")

b.p = d
b.t = m
n.p = l
c.p = b
l.p = b
l.t = h
m.p = l
a.p = l
f.p = d
h.p = d
d.p = l
d.t = f
j.p = d
assert h.p.p.t.p.t.p.p.p.p.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.p: A = None
        self.txt = txt

b = A("b")
n = B("n")
c = B("c")
l = A("l")
m = B("m")
a = B("a")
f = B("f")
h = B("h")
d = A("d")
j = B("j")

b.p = d
b.t = m
n.p = l
c.p = b
l.p = b
l.t = h
m.p = l
a.p = l
f.p = d
h.p = d
d.p = l
d.t = f
j.p = d
assert h.p.p.t.p.t.p.p.p.p.txt == "d"