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.v: A = None
        self.u: B = None
        self.txt = txt

j = A("j")
n = B("n")
d = B("d")
e = A("e")

j.p = d
j.t = n
n.v = j
n.u = d
d.v = j
d.u = n
e.p = d
e.t = d
assert d.u.v.t.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.v: A = None
        self.u: B = None
        self.txt = txt

j = A("j")
n = B("n")
d = B("d")
e = A("e")

j.p = d
j.t = n
n.v = j
n.u = d
d.v = j
d.u = n
e.p = d
e.t = d
assert d.u.v.t.txt == "n"