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

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

g = A("g")
m = B("m")
k = C("k")
c = D("c")
l = E("l")
j = D("j")
f = C("f")

g.x = l
g.r = k
m.v = f
m.x = j
k.t = l
k.x = l
k.q = c
k.y = j
c.t = j
c.o = m
c.r = g
c.x = g
l.u = f
j.t = c
j.o = m
j.r = g
j.x = g
f.t = l
f.x = l
f.q = j
f.y = j
assert f.x.u.y.x.x.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.r: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

g = A("g")
m = B("m")
k = C("k")
c = D("c")
l = E("l")
j = D("j")
f = C("f")

g.x = l
g.r = k
m.v = f
m.x = j
k.t = l
k.x = l
k.q = c
k.y = j
c.t = j
c.o = m
c.r = g
c.x = g
l.u = f
j.t = c
j.o = m
j.r = g
j.x = g
f.t = l
f.x = l
f.q = j
f.y = j
assert f.x.u.y.x.x.u.y.txt == "j"