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

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

class C:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: B = None
        self.o: D = None
        self.y: A = None
        self.w: E = None
        self.txt = txt

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: B = None
        self.o: D = None
        self.y: A = None
        self.w: E = None
        self.txt = txt

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

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

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

f.u = g
g.y = f
g.r = f
g.t = k
m.z = g
m.r = g
m.o = d
m.y = f
m.w = j
d.w = k
d.q = g
k.r = f
n.z = g
n.r = g
n.o = d
n.y = f
n.w = j
j.r = f
assert f.u.r.u.txt == "g"