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

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

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

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

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

d.r = m
d.y = m
d.v = c
d.x = k
m.o = c
m.p = c
m.u = c
k.o = d
c.q = m
c.p = m
c.t = k
c.s = k
g.r = m
g.y = m
g.v = c
g.x = k
assert g.r.u.q.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.y: B = None
        self.v: D = None
        self.x: C = None
        self.txt = txt

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

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

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

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

d.r = m
d.y = m
d.v = c
d.x = k
m.o = c
m.p = c
m.u = c
k.o = d
c.q = m
c.p = m
c.t = k
c.s = k
g.r = m
g.y = m
g.v = c
g.x = k
assert g.r.u.q.u.q.txt == "m"