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

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

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

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

b = A("b")
j = B("j")
c = C("c")
i = D("i")
l = B("l")
g = D("g")
f = D("f")
h = A("h")
m = C("m")

b.o = g
b.v = g
b.r = c
b.p = h
j.q = i
j.r = i
j.o = l
c.w = f
c.u = f
c.x = h
c.q = j
i.q = j
l.q = i
l.o = j
l.r = g
g.q = l
f.q = j
h.o = g
h.v = i
h.r = m
h.p = b
m.w = g
m.u = g
m.x = b
m.q = l
assert i.q.o.q.q.q.q.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.v: D = None
        self.r: C = None
        self.p: A = None
        self.txt = txt

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

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

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

b = A("b")
j = B("j")
c = C("c")
i = D("i")
l = B("l")
g = D("g")
f = D("f")
h = A("h")
m = C("m")

b.o = g
b.v = g
b.r = c
b.p = h
j.q = i
j.r = i
j.o = l
c.w = f
c.u = f
c.x = h
c.q = j
i.q = j
l.q = i
l.o = j
l.r = g
g.q = l
f.q = j
h.o = g
h.v = i
h.r = m
h.p = b
m.w = g
m.u = g
m.x = b
m.q = l
assert i.q.o.q.q.q.q.o.r.txt == "g"