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

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.t: C = None
        self.x: F = None
        self.q: E = None
        self.r: D = None
        self.txt = txt

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

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

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

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

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

m.x = i
m.p = i
m.y = g
m.z = j
g.w = h
g.t = h
g.x = b
g.q = j
g.r = c
h.o = g
c.s = m
j.r = b
j.y = c
b.w = j
b.y = g
b.x = h
i.x = m
i.p = m
i.y = g
i.z = j
assert g.r.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.y: B = None
        self.p: A = None
        self.z: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: C = None
        self.t: C = None
        self.x: F = None
        self.q: E = None
        self.r: D = None
        self.txt = txt

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

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

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

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

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

m.x = i
m.p = i
m.y = g
m.z = j
g.w = h
g.t = h
g.x = b
g.q = j
g.r = c
h.o = g
c.s = m
j.r = b
j.y = c
b.w = j
b.y = g
b.x = h
i.x = m
i.p = m
i.y = g
i.z = j
assert g.r.s.y.txt == "g"