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

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

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

class D:
    def __init__(self, txt: str):
        self.x: E = None
        self.y: F = None
        self.s: C = None
        self.p: F = None
        self.w: B = None
        self.txt = txt

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

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

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

m.o = n
g.o = b
g.u = b
g.t = b
d.r = b
d.p = b
d.w = m
b.x = n
b.y = k
b.p = k
b.s = d
b.w = g
n.t = k
k.u = g
k.w = g
k.r = n
f.r = b
f.p = b
f.w = j
j.o = n
assert k.w.u.y.w.t.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: E = None
        self.y: F = None
        self.s: C = None
        self.p: F = None
        self.w: B = None
        self.txt = txt

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

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

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

m.o = n
g.o = b
g.u = b
g.t = b
d.r = b
d.p = b
d.w = m
b.x = n
b.y = k
b.p = k
b.s = d
b.w = g
n.t = k
k.u = g
k.w = g
k.r = n
f.r = b
f.p = b
f.w = j
j.o = n
assert k.w.u.y.w.t.p.u.txt == "g"