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

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

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

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

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

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

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

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

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

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

g.o = m
i.z = f
i.q = g
i.w = a
f.o = e
f.y = g
m.r = g
m.u = e
m.y = e
e.o = j
a.o = g
a.y = g
j.r = e
j.u = e
j.y = g
k.z = a
k.q = g
k.w = f
assert i.w.y.o.r.o.y.o.txt == "j"