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

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

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

class D:
    def __init__(self, txt: str):
        self.w: F = None
        self.x: A = None
        self.s: C = None
        self.t: B = None
        self.z: B = None
        self.txt = txt

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

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

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

j.r = i
j.u = c
j.x = c
h.x = j
h.w = j
h.v = c
c.r = j
c.u = g
c.p = g
n.w = g
n.x = j
n.s = c
n.t = h
n.z = h
i.p = j
i.y = n
i.r = c
g.v = n
assert h.v.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.u: C = None
        self.x: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: F = None
        self.x: A = None
        self.s: C = None
        self.t: B = None
        self.z: B = None
        self.txt = txt

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

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

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

j.r = i
j.u = c
j.x = c
h.x = j
h.w = j
h.v = c
c.r = j
c.u = g
c.p = g
n.w = g
n.x = j
n.s = c
n.t = h
n.z = h
i.p = j
i.y = n
i.r = c
g.v = n
assert h.v.r.u.txt == "c"