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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: C = None
        self.w: E = None
        self.p: C = None
        self.txt = txt

h = A("h")
j = B("j")
f = C("f")
b = D("b")
e = E("e")
l = E("l")
d = A("d")
a = C("a")
g = A("g")

h.r = g
h.q = f
j.o = a
f.o = d
b.v = h
b.s = l
b.o = j
e.y = f
e.p = f
e.w = l
l.y = a
l.p = a
l.w = e
d.r = g
d.q = f
a.o = g
g.r = d
g.q = f
assert a.o.q.o.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.q: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: C = None
        self.w: E = None
        self.p: C = None
        self.txt = txt

h = A("h")
j = B("j")
f = C("f")
b = D("b")
e = E("e")
l = E("l")
d = A("d")
a = C("a")
g = A("g")

h.r = g
h.q = f
j.o = a
f.o = d
b.v = h
b.s = l
b.o = j
e.y = f
e.p = f
e.w = l
l.y = a
l.p = a
l.w = e
d.r = g
d.q = f
a.o = g
g.r = d
g.q = f
assert a.o.q.o.r.q.txt == "f"