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

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

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

class D:
    def __init__(self, txt: str):
        self.x: E = None
        self.s: E = None
        self.o: C = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.q: C = None
        self.s: D = None
        self.r: B = None
        self.txt = txt

d = A("d")
n = B("n")
c = C("c")
f = D("f")
k = E("k")
e = F("e")
i = A("i")
g = D("g")

d.r = c
n.p = f
n.r = g
c.v = f
c.w = f
c.u = e
f.x = k
f.s = k
f.o = c
k.p = g
k.u = g
k.x = n
k.w = d
k.y = d
e.q = c
e.s = f
e.r = n
i.r = c
g.x = k
g.s = k
g.o = c
assert k.p.o.w.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: E = None
        self.s: E = None
        self.o: C = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.q: C = None
        self.s: D = None
        self.r: B = None
        self.txt = txt

d = A("d")
n = B("n")
c = C("c")
f = D("f")
k = E("k")
e = F("e")
i = A("i")
g = D("g")

d.r = c
n.p = f
n.r = g
c.v = f
c.w = f
c.u = e
f.x = k
f.s = k
f.o = c
k.p = g
k.u = g
k.x = n
k.w = d
k.y = d
e.q = c
e.s = f
e.r = n
i.r = c
g.x = k
g.s = k
g.o = c
assert k.p.o.w.o.w.txt == "f"