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

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

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

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

i = A("i")
k = B("k")
f = C("f")
a = D("a")
c = C("c")
b = D("b")
e = B("e")
g = D("g")
l = C("l")

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

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

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

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

i = A("i")
k = B("k")
f = C("f")
a = D("a")
c = C("c")
b = D("b")
e = B("e")
g = D("g")
l = C("l")

i.r = g
i.y = e
i.t = e
i.q = f
k.z = e
k.x = e
k.y = e
k.q = c
f.x = e
f.o = i
f.y = b
a.y = l
c.x = k
c.o = i
c.y = a
b.y = c
e.z = k
e.x = k
e.y = k
e.q = c
g.y = c
l.x = k
l.o = i
l.y = g
assert f.y.y.x.x.q.x.txt == "k"