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

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

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

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

a = A("a")
j = B("j")
e = C("e")
m = D("m")
f = A("f")
i = B("i")
g = D("g")

a.x = f
a.o = g
j.s = f
j.y = f
j.z = g
j.p = g
e.y = g
e.t = f
m.s = g
m.w = e
m.q = f
f.x = a
f.o = g
i.s = a
i.y = a
i.z = m
i.p = g
g.s = m
g.w = e
g.q = f
assert i.s.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.o: D = None
        self.txt = txt

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

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

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

a = A("a")
j = B("j")
e = C("e")
m = D("m")
f = A("f")
i = B("i")
g = D("g")

a.x = f
a.o = g
j.s = f
j.y = f
j.z = g
j.p = g
e.y = g
e.t = f
m.s = g
m.w = e
m.q = f
f.x = a
f.o = g
i.s = a
i.y = a
i.z = m
i.p = g
g.s = m
g.w = e
g.q = f
assert i.s.o.s.txt == "m"