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

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

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

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

b = A("b")
j = B("j")
c = C("c")
k = D("k")
h = A("h")
m = B("m")

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

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

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

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

b = A("b")
j = B("j")
c = C("c")
k = D("k")
h = A("h")
m = B("m")

b.x = m
b.z = m
b.u = m
b.v = h
j.q = b
j.o = k
j.r = k
j.z = m
c.v = j
c.z = b
k.s = b
h.x = j
h.z = j
h.v = b
h.u = m
m.q = h
m.o = k
m.r = k
m.z = j
assert k.s.u.r.txt == "k"