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

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

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

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

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

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

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

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

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

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

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

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

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

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

g.r = f
e.v = h
e.u = g
e.w = m
e.p = m
e.s = m
f.w = g
b.y = m
c.x = m
c.w = f
c.p = g
m.p = b
m.q = h
h.v = e
h.u = g
h.w = m
h.p = m
h.s = m
assert h.p.p.y.q.v.txt == "e"