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

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

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

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

i = A("i")
e = B("e")
m = C("m")
b = D("b")
c = A("c")
j = B("j")
k = A("k")
n = A("n")
g = C("g")
h = B("h")

i.r = n
i.z = b
e.o = i
e.z = j
m.o = g
m.y = b
b.r = m
b.y = g
c.r = n
c.z = b
j.o = n
j.z = e
k.r = i
k.z = b
n.r = k
n.z = b
g.o = m
g.y = b
h.o = i
h.z = j
assert g.y.r.o.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.z: D = None
        self.txt = txt

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

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

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

i = A("i")
e = B("e")
m = C("m")
b = D("b")
c = A("c")
j = B("j")
k = A("k")
n = A("n")
g = C("g")
h = B("h")

i.r = n
i.z = b
e.o = i
e.z = j
m.o = g
m.y = b
b.r = m
b.y = g
c.r = n
c.z = b
j.o = n
j.z = e
k.r = i
k.z = b
n.r = k
n.z = b
g.o = m
g.y = b
h.o = i
h.z = j
assert g.y.r.o.o.y.txt == "b"