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

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

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

class D:
    def __init__(self, txt: str):
        self.p: D = None
        self.s: A = None
        self.u: C = None
        self.v: C = None
        self.txt = txt

n = A("n")
j = B("j")
c = C("c")
l = D("l")
a = D("a")

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

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

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

class D:
    def __init__(self, txt: str):
        self.p: D = None
        self.s: A = None
        self.u: C = None
        self.v: C = None
        self.txt = txt

n = A("n")
j = B("j")
c = C("c")
l = D("l")
a = D("a")

n.u = c
j.q = a
c.p = a
c.v = l
l.p = a
l.s = n
l.u = c
l.v = c
a.p = l
a.s = n
a.u = c
a.v = c
assert n.u.p.p.v.txt == "c"