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

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

f = A("f")
d = B("d")
l = A("l")
n = B("n")
i = B("i")
k = B("k")
h = A("h")

f.t = i
f.p = n
d.t = l
d.z = n
l.t = i
l.p = i
n.t = h
n.z = d
i.t = l
i.z = d
k.t = l
k.z = d
h.t = n
h.p = d
assert n.z.z.t.t.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.p: B = None
        self.txt = txt

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

f = A("f")
d = B("d")
l = A("l")
n = B("n")
i = B("i")
k = B("k")
h = A("h")

f.t = i
f.p = n
d.t = l
d.z = n
l.t = i
l.p = i
n.t = h
n.z = d
i.t = l
i.z = d
k.t = l
k.z = d
h.t = n
h.p = d
assert n.z.z.t.t.z.z.txt == "n"