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

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

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

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

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

g.q = j
g.v = b
g.r = f
g.y = m
l.o = f
i.u = c
i.s = j
c.x = i
c.o = l
c.r = m
f.o = l
m.o = l
b.q = j
b.v = g
b.r = m
b.y = f
d.x = i
d.o = m
d.r = l
j.q = g
j.v = b
j.r = m
j.y = m
assert f.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: A = None
        self.r: B = None
        self.y: B = None
        self.txt = txt

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

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

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

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

g.q = j
g.v = b
g.r = f
g.y = m
l.o = f
i.u = c
i.s = j
c.x = i
c.o = l
c.r = m
f.o = l
m.o = l
b.q = j
b.v = g
b.r = m
b.y = f
d.x = i
d.o = m
d.r = l
j.q = g
j.v = b
j.r = m
j.y = m
assert f.o.o.o.o.o.o.txt == "f"