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

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

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

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

a = A("a")
b = B("b")
g = C("g")
k = D("k")
i = C("i")
j = B("j")
e = B("e")
c = B("c")
m = D("m")

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

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

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

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

a = A("a")
b = B("b")
g = C("g")
k = D("k")
i = C("i")
j = B("j")
e = B("e")
c = B("c")
m = D("m")

a.q = g
a.u = b
a.p = b
a.v = c
b.y = i
b.u = a
g.z = i
g.q = i
g.x = b
k.r = a
k.o = m
k.x = m
k.v = i
i.z = g
i.q = g
i.x = c
j.y = g
j.u = a
e.y = i
e.u = a
c.y = g
c.u = a
m.r = a
m.o = k
m.x = k
m.v = i
assert k.v.x.y.q.q.x.y.txt == "i"