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

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

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

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

k = A("k")
i = B("i")
d = C("d")
l = D("l")
g = C("g")
b = D("b")
m = A("m")

k.u = i
k.o = i
k.s = m
k.p = m
i.z = d
d.q = g
l.y = i
g.q = d
b.y = i
m.u = i
m.o = i
m.s = k
m.p = k
assert g.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.s: A = None
        self.o: B = None
        self.p: A = None
        self.txt = txt

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

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

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

k = A("k")
i = B("i")
d = C("d")
l = D("l")
g = C("g")
b = D("b")
m = A("m")

k.u = i
k.o = i
k.s = m
k.p = m
i.z = d
d.q = g
l.y = i
g.q = d
b.y = i
m.u = i
m.o = i
m.s = k
m.p = k
assert g.q.q.q.q.txt == "g"