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

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

f = A("f")
e = B("e")
h = A("h")
b = B("b")
j = A("j")
n = B("n")

f.p = e
f.t = b
e.z = b
e.u = f
h.p = n
h.t = b
b.z = n
b.u = j
j.p = n
j.t = b
n.z = e
n.u = f
assert f.t.z.z.u.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.t: B = None
        self.txt = txt

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

f = A("f")
e = B("e")
h = A("h")
b = B("b")
j = A("j")
n = B("n")

f.p = e
f.t = b
e.z = b
e.u = f
h.p = n
h.t = b
b.z = n
b.u = j
j.p = n
j.t = b
n.z = e
n.u = f
assert f.t.z.z.u.p.u.txt == "f"