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

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

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

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

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

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

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

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

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

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

m.q = f
m.v = f
m.y = f
m.z = j
j.x = h
a.p = k
a.y = j
a.o = h
e.x = m
e.p = a
f.q = m
f.v = m
f.y = m
f.z = h
h.x = j
c.x = m
c.p = k
k.p = a
k.y = h
k.o = j
assert e.x.z.x.x.x.x.x.txt == "h"