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

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

class C:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: A = None
        self.s: A = None
        self.r: B = None
        self.txt = txt

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

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

d.o = k
d.v = a
m.o = a
m.w = a
m.q = a
a.u = c
a.q = d
a.s = d
a.r = m
k.o = e
k.y = e
k.u = a
c.o = a
c.w = a
c.q = a
e.o = k
e.y = k
e.u = a
assert a.r.o.s.v.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.v: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: A = None
        self.s: A = None
        self.r: B = None
        self.txt = txt

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

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

d.o = k
d.v = a
m.o = a
m.w = a
m.q = a
a.u = c
a.q = d
a.s = d
a.r = m
k.o = e
k.y = e
k.u = a
c.o = a
c.w = a
c.q = a
e.o = k
e.y = k
e.u = a
assert a.r.o.s.v.q.v.txt == "a"