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

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

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

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

g = A("g")
d = B("d")
h = C("h")
a = D("a")
j = D("j")
c = B("c")
m = C("m")
b = C("b")
f = D("f")

g.x = d
g.t = m
g.q = a
g.v = c
d.y = f
d.s = h
d.p = c
h.x = a
h.s = f
h.z = b
h.q = d
a.o = c
j.o = d
c.y = j
c.s = m
c.p = d
m.x = j
m.s = f
m.z = b
m.q = d
b.x = a
b.s = f
b.z = h
b.q = d
f.o = c
assert b.z.s.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.t: C = None
        self.q: D = None
        self.v: B = None
        self.txt = txt

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

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

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

g = A("g")
d = B("d")
h = C("h")
a = D("a")
j = D("j")
c = B("c")
m = C("m")
b = C("b")
f = D("f")

g.x = d
g.t = m
g.q = a
g.v = c
d.y = f
d.s = h
d.p = c
h.x = a
h.s = f
h.z = b
h.q = d
a.o = c
j.o = d
c.y = j
c.s = m
c.p = d
m.x = j
m.s = f
m.z = b
m.q = d
b.x = a
b.s = f
b.z = h
b.q = d
f.o = c
assert b.z.s.o.y.txt == "j"