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

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

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

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

c = A("c")
a = B("a")
e = C("e")
k = D("k")
m = B("m")
h = C("h")
f = D("f")
i = A("i")
d = D("d")
g = C("g")

c.r = a
c.x = d
c.q = i
c.u = g
a.o = m
a.x = g
e.x = c
e.z = h
k.y = g
m.o = a
m.x = e
h.x = i
h.z = g
f.y = e
i.r = a
i.x = k
i.q = c
i.u = e
d.y = e
g.x = c
g.z = h
assert d.y.x.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: D = None
        self.q: A = None
        self.u: C = None
        self.txt = txt

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

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

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

c = A("c")
a = B("a")
e = C("e")
k = D("k")
m = B("m")
h = C("h")
f = D("f")
i = A("i")
d = D("d")
g = C("g")

c.r = a
c.x = d
c.q = i
c.u = g
a.o = m
a.x = g
e.x = c
e.z = h
k.y = g
m.o = a
m.x = e
h.x = i
h.z = g
f.y = e
i.r = a
i.x = k
i.q = c
i.u = e
d.y = e
g.x = c
g.z = h
assert d.y.x.q.q.q.txt == "i"