class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.v: F = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: F = None
        self.txt = txt

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

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

f.u = e
f.v = g
c.w = e
c.v = g
c.x = j
m.v = j
m.u = f
k.q = e
e.x = g
g.o = k
g.w = e
g.r = c
j.v = m
j.u = i
i.u = e
i.v = g
l.q = e
a.q = e
assert m.u.v.o.q.x.o.q.x.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.v: F = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: F = None
        self.txt = txt

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

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

f.u = e
f.v = g
c.w = e
c.v = g
c.x = j
m.v = j
m.u = f
k.q = e
e.x = g
g.o = k
g.w = e
g.r = c
j.v = m
j.u = i
i.u = e
i.v = g
l.q = e
a.q = e
assert m.u.v.o.q.x.o.q.x.w.x.txt == "g"