class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: F = None
        self.p: C = None
        self.q: F = None
        self.u: F = None
        self.txt = txt

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

m = A("m")
h = B("h")
k = C("k")
d = D("d")
c = E("c")
l = F("l")
a = D("a")

m.y = a
h.u = l
h.v = c
k.x = c
d.p = m
d.x = m
d.y = l
d.u = a
d.w = h
d.r = h
c.r = l
c.q = l
c.u = l
c.p = k
l.p = a
l.s = k
l.r = c
a.p = m
a.x = m
a.y = l
a.u = d
a.w = h
a.r = h
assert d.r.u.r.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: F = None
        self.p: C = None
        self.q: F = None
        self.u: F = None
        self.txt = txt

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

m = A("m")
h = B("h")
k = C("k")
d = D("d")
c = E("c")
l = F("l")
a = D("a")

m.y = a
h.u = l
h.v = c
k.x = c
d.p = m
d.x = m
d.y = l
d.u = a
d.w = h
d.r = h
c.r = l
c.q = l
c.u = l
c.p = k
l.p = a
l.s = k
l.r = c
a.p = m
a.x = m
a.y = l
a.u = d
a.w = h
a.r = h
assert d.r.u.r.p.x.txt == "c"