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

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

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

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

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

j = A("j")
n = B("n")
m = C("m")
g = D("g")
d = E("d")
k = A("k")

j.t = g
j.w = n
j.o = n
j.y = k
n.t = g
m.v = d
m.r = n
m.t = k
g.v = n
d.r = n
k.t = g
k.w = n
k.o = n
k.y = j
assert d.r.t.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.w: B = None
        self.o: B = None
        self.y: A = None
        self.txt = txt

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

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

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

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

j = A("j")
n = B("n")
m = C("m")
g = D("g")
d = E("d")
k = A("k")

j.t = g
j.w = n
j.o = n
j.y = k
n.t = g
m.v = d
m.r = n
m.t = k
g.v = n
d.r = n
k.t = g
k.w = n
k.o = n
k.y = j
assert d.r.t.v.t.txt == "g"