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

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

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

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

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

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

j.r = a
j.u = e
c.p = f
c.w = a
e.y = a
e.u = d
e.v = j
e.r = j
a.y = b
a.r = c
f.r = a
f.y = a
b.r = a
b.y = a
d.r = a
d.u = e
assert a.r.p.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.u: C = None
        self.txt = txt

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

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

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

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

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

j.r = a
j.u = e
c.p = f
c.w = a
e.y = a
e.u = d
e.v = j
e.r = j
a.y = b
a.r = c
f.r = a
f.y = a
b.r = a
b.y = a
d.r = a
d.u = e
assert a.r.p.y.r.txt == "c"