class A:
    def __init__(self, txt: str):
        self.t: E = None
        self.v: E = None
        self.q: E = None
        self.p: C = None
        self.s: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

a.t = c
a.v = c
a.q = c
a.p = g
a.s = d
b.r = d
b.y = g
b.t = g
b.q = a
g.w = d
d.v = c
c.o = d
c.w = k
k.r = d
k.y = g
k.t = g
k.q = a
assert a.v.w.y.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: E = None
        self.v: E = None
        self.q: E = None
        self.p: C = None
        self.s: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

a.t = c
a.v = c
a.q = c
a.p = g
a.s = d
b.r = d
b.y = g
b.t = g
b.q = a
g.w = d
d.v = c
c.o = d
c.w = k
k.r = d
k.y = g
k.t = g
k.q = a
assert a.v.w.y.w.v.txt == "c"