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

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

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

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

l = A("l")
c = B("c")
h = C("h")
m = D("m")
k = D("k")
d = A("d")

l.x = c
l.u = d
c.r = k
c.p = h
h.s = k
h.w = c
h.x = c
m.v = l
m.q = c
m.z = h
k.v = d
k.q = c
k.z = h
d.x = c
d.u = l
assert l.x.p.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.u: A = None
        self.txt = txt

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

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

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

l = A("l")
c = B("c")
h = C("h")
m = D("m")
k = D("k")
d = A("d")

l.x = c
l.u = d
c.r = k
c.p = h
h.s = k
h.w = c
h.x = c
m.v = l
m.q = c
m.z = h
k.v = d
k.q = c
k.z = h
d.x = c
d.u = l
assert l.x.p.s.q.txt == "c"