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

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

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

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

c = A("c")
d = B("d")
j = C("j")
l = D("l")
a = D("a")
b = D("b")
m = D("m")

c.v = j
d.z = a
d.x = j
j.v = c
j.x = c
j.u = m
l.s = j
l.v = j
l.x = m
a.s = j
a.v = j
a.x = m
b.s = j
b.v = j
b.x = a
m.s = j
m.v = j
m.x = l
assert m.x.x.x.x.x.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

c = A("c")
d = B("d")
j = C("j")
l = D("l")
a = D("a")
b = D("b")
m = D("m")

c.v = j
d.z = a
d.x = j
j.v = c
j.x = c
j.u = m
l.s = j
l.v = j
l.x = m
a.s = j
a.v = j
a.x = m
b.s = j
b.v = j
b.x = a
m.s = j
m.v = j
m.x = l
assert m.x.x.x.x.x.v.x.txt == "c"