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

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

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

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

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

i.o = j
i.r = e
i.y = c
i.u = n
b.y = e
m.o = j
m.r = b
m.v = n
c.x = n
c.p = j
c.v = b
n.o = j
n.r = b
n.v = m
e.o = j
e.y = j
e.r = i
e.u = m
j.x = m
j.p = c
j.v = b
assert j.x.v.o.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.r: A = None
        self.y: D = None
        self.u: C = None
        self.txt = txt

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

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

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

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

i.o = j
i.r = e
i.y = c
i.u = n
b.y = e
m.o = j
m.r = b
m.v = n
c.x = n
c.p = j
c.v = b
n.o = j
n.r = b
n.v = m
e.o = j
e.y = j
e.r = i
e.u = m
j.x = m
j.p = c
j.v = b
assert j.x.v.o.p.p.txt == "j"