class A:
    def __init__(self, txt: str):
        self.o: F = None
        self.u: D = None
        self.x: D = None
        self.q: C = None
        self.txt = txt

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

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

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

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

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

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

i.o = g
i.u = n
i.x = n
i.q = c
j.o = m
c.r = g
c.x = g
n.y = g
n.u = c
b.y = n
g.u = i
g.r = c
g.s = c
m.y = n
assert i.o.s.r.u.x.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: F = None
        self.u: D = None
        self.x: D = None
        self.q: C = None
        self.txt = txt

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

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

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

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

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

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

i.o = g
i.u = n
i.x = n
i.q = c
j.o = m
c.r = g
c.x = g
n.y = g
n.u = c
b.y = n
g.u = i
g.r = c
g.s = c
m.y = n
assert i.o.s.r.u.x.u.r.txt == "g"