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

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

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.txt = txt

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

f = A("f")
g = B("g")
b = C("b")
d = D("d")
c = E("c")
a = A("a")

f.p = c
f.y = b
f.r = g
f.q = a
g.z = f
g.r = c
g.q = d
b.v = a
b.p = d
b.u = d
d.t = c
c.o = b
c.x = a
a.p = c
a.y = b
a.r = g
a.q = f
assert g.r.o.v.r.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.y: C = None
        self.r: B = None
        self.q: A = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.txt = txt

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

f = A("f")
g = B("g")
b = C("b")
d = D("d")
c = E("c")
a = A("a")

f.p = c
f.y = b
f.r = g
f.q = a
g.z = f
g.r = c
g.q = d
b.v = a
b.p = d
b.u = d
d.t = c
c.o = b
c.x = a
a.p = c
a.y = b
a.r = g
a.q = f
assert g.r.o.v.r.r.x.txt == "a"