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

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

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

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

g = A("g")
m = B("m")
h = C("h")
c = D("c")
k = A("k")
a = A("a")

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

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

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

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

g = A("g")
m = B("m")
h = C("h")
c = D("c")
k = A("k")
a = A("a")

g.q = h
g.p = c
g.r = m
g.o = m
m.p = g
m.y = g
m.r = c
m.u = c
h.q = c
c.z = g
c.p = m
k.q = h
k.p = c
k.r = m
k.o = m
a.q = h
a.p = c
a.r = m
a.o = m
assert m.y.q.q.p.u.txt == "c"