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

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

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

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

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

j.v = c
f.v = j
f.u = j
f.t = n
d.z = j
d.p = c
d.q = l
d.r = l
n.o = f
c.v = j
l.z = j
l.p = j
l.q = d
l.r = d
assert c.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

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

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

j.v = c
f.v = j
f.u = j
f.t = n
d.z = j
d.p = c
d.q = l
d.r = l
n.o = f
c.v = j
l.z = j
l.p = j
l.q = d
l.r = d
assert c.v.v.v.txt == "j"