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

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

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

n = A("n")
j = B("j")
a = C("a")
l = D("l")
i = B("i")
m = A("m")
f = D("f")
b = B("b")
c = D("c")

n.x = i
j.p = m
j.z = n
a.x = c
l.p = c
i.p = n
i.z = m
m.x = i
f.p = l
b.p = m
b.z = n
c.p = f
assert c.p.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

n = A("n")
j = B("j")
a = C("a")
l = D("l")
i = B("i")
m = A("m")
f = D("f")
b = B("b")
c = D("c")

n.x = i
j.p = m
j.z = n
a.x = c
l.p = c
i.p = n
i.z = m
m.x = i
f.p = l
b.p = m
b.z = n
c.p = f
assert c.p.p.p.p.p.p.p.txt == "f"