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

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

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

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

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

d.q = k
d.o = j
d.t = m
d.r = m
f.z = c
f.x = j
j.o = k
j.v = d
c.o = d
c.y = k
c.x = a
c.w = e
m.z = e
m.x = a
e.o = d
e.y = k
e.x = j
e.w = c
k.q = d
k.o = a
k.t = m
k.r = m
a.o = k
a.v = d
assert e.o.q.q.o.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.o: C = None
        self.t: B = None
        self.r: B = None
        self.txt = txt

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

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

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

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

d.q = k
d.o = j
d.t = m
d.r = m
f.z = c
f.x = j
j.o = k
j.v = d
c.o = d
c.y = k
c.x = a
c.w = e
m.z = e
m.x = a
e.o = d
e.y = k
e.x = j
e.w = c
k.q = d
k.o = a
k.t = m
k.r = m
a.o = k
a.v = d
assert e.o.q.q.o.o.r.txt == "m"