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

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

n = A("n")
l = B("l")
c = A("c")
j = B("j")

n.u = c
l.p = c
l.u = c
c.u = n
j.p = c
j.u = c
assert c.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

n = A("n")
l = B("l")
c = A("c")
j = B("j")

n.u = c
l.p = c
l.u = c
c.u = n
j.p = c
j.u = c
assert c.u.u.u.txt == "n"