class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: B = None
        self.w: F = None
        self.r: E = None
        self.s: F = None
        self.p: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.w: C = None
        self.u: C = None
        self.z: A = None
        self.y: B = None
        self.r: B = 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: E = None
        self.txt = txt

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

c = A("c")
n = B("n")
m = C("m")
g = D("g")
l = E("l")
b = F("b")
h = C("h")
d = E("d")

c.q = n
c.v = n
c.w = b
c.s = b
c.p = b
c.r = d
n.q = g
n.u = g
n.r = d
m.p = g
m.w = h
m.u = h
m.z = c
m.y = n
m.r = n
g.q = d
l.x = d
b.r = g
b.u = n
h.p = g
h.w = m
h.u = m
h.z = c
h.y = n
h.r = n
d.x = l
assert c.p.u.r.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: B = None
        self.w: F = None
        self.r: E = None
        self.s: F = None
        self.p: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.w: C = None
        self.u: C = None
        self.z: A = None
        self.y: B = None
        self.r: B = 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: E = None
        self.txt = txt

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

c = A("c")
n = B("n")
m = C("m")
g = D("g")
l = E("l")
b = F("b")
h = C("h")
d = E("d")

c.q = n
c.v = n
c.w = b
c.s = b
c.p = b
c.r = d
n.q = g
n.u = g
n.r = d
m.p = g
m.w = h
m.u = h
m.z = c
m.y = n
m.r = n
g.q = d
l.x = d
b.r = g
b.u = n
h.p = g
h.w = m
h.u = m
h.z = c
h.y = n
h.r = n
d.x = l
assert c.p.u.r.x.x.x.x.txt == "d"