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

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

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

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

e = A("e")
a = B("a")
f = C("f")
j = D("j")
b = D("b")
g = C("g")

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

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

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

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

e = A("e")
a = B("a")
f = C("f")
j = D("j")
b = D("b")
g = C("g")

e.r = g
e.u = a
a.r = f
a.q = f
a.s = e
f.o = a
j.v = b
j.u = b
j.p = g
j.r = e
b.v = j
b.u = j
b.p = g
b.r = e
g.o = a
assert j.p.o.r.o.s.u.txt == "a"