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

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

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

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

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

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

k = A("k")
g = B("g")
c = C("c")
h = D("h")
m = E("m")
n = F("n")
f = B("f")
b = B("b")
i = E("i")

k.x = c
k.v = f
g.x = c
g.q = f
g.t = b
c.p = f
h.v = g
m.p = f
m.r = k
m.u = i
m.w = h
n.r = i
n.t = c
n.y = k
f.x = c
f.q = b
f.t = b
b.x = c
b.q = g
b.t = f
i.p = b
i.r = k
i.u = m
i.w = h
assert k.v.x.p.q.x.p.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.v: B = None
        self.txt = txt

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

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

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

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

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

k = A("k")
g = B("g")
c = C("c")
h = D("h")
m = E("m")
n = F("n")
f = B("f")
b = B("b")
i = E("i")

k.x = c
k.v = f
g.x = c
g.q = f
g.t = b
c.p = f
h.v = g
m.p = f
m.r = k
m.u = i
m.w = h
n.r = i
n.t = c
n.y = k
f.x = c
f.q = b
f.t = b
b.x = c
b.q = g
b.t = f
i.p = b
i.r = k
i.u = m
i.w = h
assert k.v.x.p.q.x.p.x.p.txt == "f"